package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 用于查询客户当天用餐计划
 *
 */
@Entity
@Table(name = "tnb_customer_day_food_plan")
@JsonApiResource(type = "customerdayfoodplan")
public class CustomerDayFoodPlan extends BaseEntity {
	// implements Comparable<CustomerDayFoodPlan> {

	private Integer diningDate;

	private String remark;
	
	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间
	
	private List<CustomerFoodPlan> plans;
	
	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "lastUpdateUser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "dining_date")
	public Integer getDiningDate() {
		return diningDate;
	}

	public void setDiningDate(Integer diningDate) {
		this.diningDate = diningDate;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}


	@Transient
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public List<CustomerFoodPlan> getPlans() {
		return plans;
	}

	public void setPlans(List<CustomerFoodPlan> plans) {
		this.plans = plans;
	}

	// @Override
	// public int compareTo(CustomerDayFoodPlan o) {
	// long date1 = this.getDate();
	//
	// long date2 = o.getDate();
	//
	// if (date1 == date2) {
	// return 0;
	// }
	// if (date1 < date2) {
	// return -1;
	// }
	// if (date1 > date2) {
	// return 1;
	// }
	// return 0;
	//
	// }
	//
	// public long getDate() {
	// if (this.getItem() != null) {
	// return Long.parseLong(this.getItem().getStartTimeTab());
	// }
	// if (this.getProject() != null) {
	// return Long.parseLong(this.getProject().getUseDrugDate());
	// }
	// return 0;
	// }

}
